
let upload = (that) => {
	
	return new Promise((resolve, reject)=>{
		uni.chooseImage({
		    count: 1,
		    success(res) {
		        const tempFilePaths = res.tempFilePaths;
				let baseUrl = uni.getStorageSync("baseUrl")
				uni.uploadFile({
				    url: baseUrl + '/doctor/file/uploadPic',
					name: "file",
					filePath: tempFilePaths[0],
				    header: {
				        "Content-Type": "multipart/form-data",
				        'Authorization': uni.getStorageSync('token')
				    },
				    success(response) {
						console.log(response)
						let data = JSON.parse(response.data)
						
						if(response.statusCode == 200){
							if(data.status == 200){
								resolve(data)
							}
							else{
								reject(data)
							}
						}
						else{
							reject(data)
						}
				    },
				    fail(res) {
				        reject(res)
				    }
				})
		    },
		    fail(res) {
		        reject(res)
		    }
		})
	})
}

export default upload